package logic

import (
	"context"
	"goods-login/cache"
	"math/rand"
	"time"

	"goods-login/goods/goods"
	"goods-login/goods/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type SmsLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewSmsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SmsLogic {
	return &SmsLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *SmsLogic) Sms(in *goods.SmsRequest) (*goods.SmsResponse, error) {
	// todo: add your logic here and delete this line
	code := rand.Intn(9000) + 1000
	cache.Rdb.Set(l.ctx, "Sms", code, time.Minute*3)
	return &goods.SmsResponse{}, nil
}
